package org.extreme.schooltalk;

import java.util.HashMap;

import android.content.SharedPreferences;
import android.util.Log;

public class PreferenceController {
	SharedPreferences sp;
	PreferenceController(SharedPreferences sp){
		this.sp = sp;
	}
	
	public void setPreferenceMyProfile(HashMap<String,String> map){
		SharedPreferences.Editor editor = sp.edit();
		editor.putString(ParameterManager._EMAIL, map.get(ParameterManager._EMAIL));
		editor.putString(ParameterManager._PASSWORD, map.get(ParameterManager._PASSWORD));
		editor.putString(ParameterManager._CONTACT, map.get(ParameterManager._CONTACT));
		editor.putString(ParameterManager._NICKNAME, map.get(ParameterManager._NICKNAME));
		editor.putString(ParameterManager._BIRTHDAY, map.get(ParameterManager._BIRTHDAY));
		editor.putString(ParameterManager._SEX, map.get(ParameterManager._SEX));
		editor.putString(ParameterManager._INTRODUCE, map.get(ParameterManager._INTRODUCE));
		editor.putString(ParameterManager._ELEMENT_SCHOOL, map.get(ParameterManager._ELEMENT_SCHOOL));
		editor.putString(ParameterManager._MIDDLE_SCHOOL, map.get(ParameterManager._MIDDLE_SCHOOL));
		editor.putString(ParameterManager._HIGH_SCHOOL, map.get(ParameterManager._HIGH_SCHOOL));
		editor.putString(ParameterManager._COLLEGE, map.get(ParameterManager._COLLEGE));
		editor.commit();
		Log.i(CommonUtils._LOG_TAG,"profile saved");
	}
	public void setPreferenceMyProfile(UserDTO dto){
		SharedPreferences.Editor editor = sp.edit();
		editor.putString(ParameterManager._EMAIL, dto.getEmail());
		editor.putString(ParameterManager._PASSWORD, dto.getPassword());
		editor.putString(ParameterManager._CONTACT, dto.getContact());
		editor.putString(ParameterManager._NICKNAME, dto.getNickname());
		editor.putString(ParameterManager._BIRTHDAY, dto.getBirth());
		editor.putString(ParameterManager._SEX, dto.getSex());
		editor.putString(ParameterManager._INTRODUCE, dto.getIntroduce());
		editor.putString(ParameterManager._ELEMENT_SCHOOL, dto.getElement_school());
		editor.putString(ParameterManager._MIDDLE_SCHOOL, dto.getMiddle_school());
		editor.putString(ParameterManager._HIGH_SCHOOL, dto.getHigh_school());
		editor.putString(ParameterManager._COLLEGE, dto.getCollege());
		editor.putString(ParameterManager._ELEMENT_SCHOOL_NAME, dto.getElement_school_name());
		editor.putString(ParameterManager._MIDDLE_SCHOOL_NAME, dto.getMiddle_school_name());
		editor.putString(ParameterManager._HIGH_SCHOOL_NAME, dto.getHigh_school_name());
		editor.putString(ParameterManager._COLLEGE_NAME, dto.getCollege_name());
		editor.commit();
		Log.i(CommonUtils._LOG_TAG,"profile saved");
	}
	
	public void setLogin(Boolean check){
		SharedPreferences.Editor editor = sp.edit();
		editor.putBoolean(ParameterManager._PREFERENCE_AUTOLOGIN_BOOLEAN, check);
		editor.commit();
	}
}
